package es.udc.emarketapp.emarket.model.shoppingFacade;

import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.*;
import es.udc.emarketapp.emarket.model.orderDetails.vo.OrderDetailsVO;
import es.udc.emarketapp.emarket.model.orderLine.vo.OrderLineVO;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.CreateOrderAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.CreateOrderLineAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.CreatePurchaseAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.DeleteOrderAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.DeleteOrderLineAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.DeletePurchaseAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindAllPurchasesAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindOrderDetailsByIdAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindOrderLineByIdAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindOrderLinesByOrderAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindOrdersDetailsBySellerAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindPurchaseByIdAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.FindPurchasesByClientAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.ModifyOrderAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.ModifyOrderLineAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions.ModifyPurchaseAction;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.vo.OrderChunkVO;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.vo.OrderLineChunkVO;
import es.udc.emarketapp.emarket.model.purchase.purchaseFacade.vo.PurchaseChunkVO;
import es.udc.emarketapp.emarket.model.purchase.vo.PurchaseVO;
import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.exceptions.ModelException;
import es.udc.fbellas.j2ee.util.sql.PlainActionProcessor;
import es.udc.fbellas.j2ee.util.sql.SimpleDataSource;
import javax.sql.DataSource;

public class ShoppingFacade111 {

	private DataSource dataSource;

	public ShoppingFacade111() throws InternalErrorException {

		dataSource = new SimpleDataSource();

	}


	public PurchaseVO register(PurchaseVO purchaseVO)
			throws InternalErrorException {

		try {

			CreatePurchaseAction action = new CreatePurchaseAction(purchaseVO);

			return (PurchaseVO) PlainActionProcessor
					.process(dataSource, action);

		} catch (InternalErrorException e) {
			throw e;
		} catch (ModelException e) {
			throw new InternalErrorException(e);
		}
	} // createPurchase



       /*

	public PurchaseVO findPurchaseById(Long idPurchase)
			throws InternalErrorException {

		try {

			FindPurchaseByIdAction action = new FindPurchaseByIdAction(
					idPurchase);

			return (PurchaseVO) PlainActionProcessor
					.process(dataSource, action);

		} catch (InternalErrorException e) {
			throw e;
		} catch (ModelException e) {
			throw new InternalErrorException(e);
		}
	} // findPurchaseById

	public PurchaseChunkVO findPurchasesByClient(String idClient,
			int startIndex, int count) throws InternalErrorException {

		try {

			FindPurchasesByClientAction action = new FindPurchasesByClientAction(
					idClient, startIndex, count);

			return (PurchaseChunkVO) PlainActionProcessor.process(dataSource,
					action);

		} catch (InternalErrorException e) {
			throw e;
		} catch (ModelException e) {
			throw new InternalErrorException(e);
		}

	} // findPurchasesByClient

	public PurchaseChunkVO findAllPurchases(int startIndex, int count)
			throws InternalErrorException {

		try {

			FindAllPurchasesAction action = new FindAllPurchasesAction(
					startIndex, count);

			return (PurchaseChunkVO) PlainActionProcessor.process(dataSource,
					action);

		} catch (InternalErrorException e) {
			throw e;
		} catch (ModelException e) {
			throw new InternalErrorException(e);
		}

	} // findAllPurchases

	public void modifyPurchase(PurchaseVO purchaseVO)
			throws InstanceNotFoundException, InternalErrorException {

		try {

			ModifyPurchaseAction action = new ModifyPurchaseAction(purchaseVO);
			PlainActionProcessor.process(dataSource, action);

		} catch (InstanceNotFoundException e) {
			throw e;
		} catch (InternalErrorException e) {
			throw e;
		} catch (Exception e) {
			throw new InternalErrorException(e);
		}

	} // modifyPurchase

	public void deletePurchase(Long idPurchase)
			throws InstanceNotFoundException, InternalErrorException {

		try {

			DeletePurchaseAction action = new DeletePurchaseAction(idPurchase);
			PlainActionProcessor.process(dataSource, action);

		} catch (InstanceNotFoundException e) {
			throw e;
		} catch (InternalErrorException e) {
			throw e;
		} catch (Exception e) {
			throw new InternalErrorException(e);
		}

	} // deletePurchase

        */


} // class

